package org.starsource.forum.client.domain;

import org.starsource.forum.client.util.Assertion;
import com.google.gwt.user.client.rpc.IsSerializable;

public class UserObject implements IsSerializable {
//	private static org.apache.log4j.Logger logger = org.apache.log4j.LogManager
//	.getLogger(UserObject.class.getName());

	private int id;
	
	private String account;

	private String password;
	
	private String name;
	
	private String directory;
	
	public UserObject() {}
	
	public UserObject(String account, String password, String name, String directory) {
		this.account = account;
		this.password =password;
		this.name = name;
		this.directory = directory;
	}

	public UserObject(int id, String account, String password, String name, String directory) {
		this.id = id;
		this.account = account;
		this.password =password;
		this.name = name;
		this.directory = directory;
	}
	
	@Override
	public boolean equals(Object obj) {
		try {
			UserObject object = (UserObject)obj;
			
			if (this.id != object.id) {
//				logger.debug("UserObject.id is not equal");
				return false;
			}
			
			if (!Assertion.isEqual(this.account, object.account)) {
//				logger.debug("this.account != object.account");
				return false;
			}
			
			if (!Assertion.isEqual(this.password, object.password)) {
//				logger.debug("this.password != object.password");
				return false;
			}
			
			if (!Assertion.isEqual(this.name, object.name)) {
//				logger.debug("this.name != object.name");
				return false;
			}
			
			if (!Assertion.isEqual(this.directory, object.directory)) {
//				logger.debug("this.directory != object.directory");
				return false;
			}
			
			return true;
		} catch (Exception e) {
//			logger.debug("exception, return false");
			return false;
		}
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDirectory() {
		return directory;
	}

	public void setDirectory(String directory) {
		this.directory = directory;
	}

}
